import {
    HYEventStore
} from "hy-event-store"
import {
    getRanKings
} from "../service/api_music"
const rankingMap = {
    0: "newRanking",
    1: "hotRanking",
    2: "originRanking",
    3: "upRanking"
}
const rankingStore = new HYEventStore({
    state: {
        newRanking: {}, //新歌
        hotRanking: {}, //热门
        originRanking: {}, //原创
        upRanking: {} //飙升版
    },
    actions: {
        getRanKingDateAction(ctx) {
            // 0新歌版 1热歌版 2原创版 3飙升版
            for (let i = 0; i < 4; i++) {
                getRanKings(i).then(res => {
                   const rankName =  rankingMap[i] 
                   ctx[rankName] = res.playlist
                })
            }
        }
    }
})

export {
    rankingStore
}